package com.wetao.testrxjava.dagger;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.wetao.testrxjava.MyApplication;
import com.wetao.testrxjava.R;

import javax.inject.Inject;

public class Dagger2Activity extends AppCompatActivity {

    TextView tv;

    @Inject
    Cloth redCloth;

    @Inject
    ClothHandler clothHandler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dagger2);
        tv = findViewById(R.id.tv);
        Dagger2ActivityComponent build = DaggerDagger2ActivityComponent
                .builder()
                .baseComponent(((MyApplication)getApplication()).getBaseComponent())
                .dagger2ActivityModule(new Dagger2ActivityModule())
                .build();
        build.inject(this);
        tv.setText("红布料加工后变成了" + clothHandler.handle(redCloth) + "\nclothHandler地址:" + clothHandler);
    }
}
